<?php Temp::Tinclude("commom/admin_header");?>
       <div class="padding_left_right">
<button type="button" id="menuadd" class="btn btn-primary">（新增）添加菜单</button>


<script type="text/javascript">
    function addDiyDom(treeId, treeNode) {
        var aObj = $("#" + treeNode.tId + "_a");
        aObj.append("<a style='float:right;padding:2px 3px;' onclick=\"window.location.href=\'?menu/delete&id="+treeNode.id+"\';return false;\">删除</a><a style='float:right;padding:2px 3px;' onclick=\"window.location.href=\'?menu/edit&id="+treeNode.id+"\';return false;\">编辑</a><a style='float:right;padding:2px 3px;' onclick=\"window.location.href=\'?menu/addbypid&pid="+treeNode.id+"\';return false;\">添加子菜单</a>");
    }
  
		var setting = {
                        data: {
				simpleData:{
				enable: true
				}
			},
                        view:{
                            showLine: false,
			    showIcon: false,
			    selectedMulti: false,
			    dblClickExpand: false,
                            addDiyDom: addDiyDom
                        }
                    };
                var zNodes=<?php echo $menulist;?>;
                 
		$(document).ready(function(){
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
               $("#menuadd").on("click",function(){
                   window.location.href="?menu/index";
               });
	</script>
 
        <ul id="treeDemo" class="ztree margin_top20">
            
        </ul>
        </div>
<?php Temp::Tinclude("commom/admin_footer");?>